//
//  UIBarButtonItem+Extension.m
//  柳州微博
//
//  Created by Apple_Lzzy40 on 16/9/19.
//  Copyright © 2016年 Apple_Lzzy40. All rights reserved.
//

#import "UIBarButtonItem+Extension.h"

@implementation UIBarButtonItem (Extension)
/**
 *  UIBarButtonItem   分类方法
 *
 *  @param target            响应方法所在的目标对象
 *  @param action            响应方法
 *  @param iamge             常态图片
 *  @param highLiightedImage 高亮图片
 *
 *  @return UIBarButtonItem
 */

+(UIBarButtonItem *)itemWithTarget:(id)target  action:(SEL)action  iamge:(NSString *)iamge  highLiightedImage:(NSString *)highLiightedImage
{
    //自定义按钮
    UIButton *Btn=[UIButton buttonWithType:UIButtonTypeCustom];
    
    //响应事件
    [Btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    //设置常态图片
    [Btn setBackgroundImage:[UIImage imageNamed:iamge] forState:UIControlStateNormal];
    
    //设置高亮图片
    [Btn setBackgroundImage:[UIImage imageNamed:highLiightedImage] forState:UIControlStateHighlighted];
    
    Btn.size =Btn.currentBackgroundImage.size;
    
    return [[UIBarButtonItem alloc]initWithCustomView:Btn];
    
}

@end
